package com.hzncc.flowable_diboot.project_contracts.dto;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.hzncc.flowable_diboot.project_contracts.entity.ProjectSamContract;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
* 项目类产品供销合同 DTO定义
*
* @author MyName
* @version 1.0
* @date 2024-09-26
 * Copyright © MyCorp
*/
@Getter
@Setter
@Accessors(chain = true)
public class ProjectSamContractDTO extends ProjectSamContract  {
private static final long serialVersionUID = 1447858784382574148L;

        /**
        * 签订时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime signingTime;
        /**
        * 签订时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "signing_time")
        private LocalDate signingTimeBegin;

        /**
        * 签订时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "signing_time")
        private LocalDate signingTimeEnd;
        /**
        * 预付款金额 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "prepayment_amount")
        private BigDecimal prepaymentAmountBegin;

        /**
        * 预付款金额 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "prepayment_amount")
        private BigDecimal prepaymentAmountEnd;
        /**
        * 余款金额 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "remaining_amount")
        private BigDecimal remainingAmountBegin;

        /**
        * 余款金额 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "remaining_amount")
        private BigDecimal remainingAmountEnd;
        /**
        * 签订后付款比例 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "payment_ratio_post_signing")
        private BigDecimal paymentRatioPostSigningBegin;

        /**
        * 签订后付款比例 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "payment_ratio_post_signing")
        private BigDecimal paymentRatioPostSigningEnd;
        /**
        * 到货后付款比例 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "payment_ratio_post_arrival")
        private BigDecimal paymentRatioPostArrivalBegin;

        /**
        * 到货后付款比例 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "payment_ratio_post_arrival")
        private BigDecimal paymentRatioPostArrivalEnd;
        /**
        * 验收后付款比例 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "payment_ratio_post_qualified_inspection")
        private BigDecimal paymentRatioPostQualifiedInspectionBegin;

        /**
        * 验收后付款比例 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "payment_ratio_post_qualified_inspection")
        private BigDecimal paymentRatioPostQualifiedInspectionEnd;
        /**
        * 年质保后付清 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "annual_warranty_and_then_pay_off_all")
        private BigDecimal annualWarrantyAndThenPayOffAllBegin;

        /**
        * 年质保后付清 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "annual_warranty_and_then_pay_off_all")
        private BigDecimal annualWarrantyAndThenPayOffAllEnd;
        /**
        * 乙方向甲方付款比例 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "payment_ratio_from_b_to_a")
        private BigDecimal paymentRatioFromBToABegin;

        /**
        * 乙方向甲方付款比例 截止
        */
        @BindQuery(comparison = Comparison.LE, column = "payment_ratio_from_b_to_a")
        private BigDecimal paymentRatioFromBToAEnd;
        /**
        * 创建时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime createTime;
        /**
        * 创建时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "create_time")
        private LocalDate createTimeBegin;

        /**
        * 创建时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "create_time")
        private LocalDate createTimeEnd;
        /**
        * 更新时间
        */
        @BindQuery(comparison = Comparison.GE)
        private LocalDateTime updateTime;
        /**
        * 更新时间 起始
        */
        @BindQuery(comparison = Comparison.GE, column = "update_time")
        private LocalDate updateTimeBegin;

        /**
        * 更新时间 截止
        */
        @BindQuery(comparison = Comparison.LT, column = "update_time")
        private LocalDate updateTimeEnd;

        public LocalDate getSigningTimeEnd() {
            if (getSigningTime() != null) {
                return getSigningTime().plusDays(1).toLocalDate();
            }
            if (signingTimeEnd != null) {
                return signingTimeEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getCreateTimeEnd() {
            if (getCreateTime() != null) {
                return getCreateTime().plusDays(1).toLocalDate();
            }
            if (createTimeEnd != null) {
                return createTimeEnd.plusDays(1);
            }
            return null;
        }
        public LocalDate getUpdateTimeEnd() {
            if (getUpdateTime() != null) {
                return getUpdateTime().plusDays(1).toLocalDate();
            }
            if (updateTimeEnd != null) {
                return updateTimeEnd.plusDays(1);
            }
            return null;
        }

}